pp108 : oncollapse Property

oncollapse Property


This is an optional property that contains the pointer to a function to be to be called when an item in the tree is collapsed.

Syntax

XML

<TreeItem>
    <searchPath>sName</searchPath>
    <description>sDesc</description>
    <oncollapse>fpFunction</oncollapse>
        ...
        ...
        ...
</TreeItem>


Parameters

Parameter

Description

fpFunction

Pointer to a function that is to be called when an item in the tree is collapsed.


Remarks


This property should be set to a tree Item which has children under it (Nodes).

When the "" icon of an expanded tree item is clicked, an event oncollapse will be fired for that item and the item is collapsed. After expanding, the function associated with the event is invoked. The event is fired and the associated function handler is called when a tree item is removed from the tree. Once an item in expanded, it will have a "+" symbol in place of "" indicating that the item is not expanded.

If the return value of the function is set to 'false', then the item will not be collapsed.

Example


The following example shows how the property is used.

<!-- Schema for tree. "collapseHandler" is a function that will be called when item is collapse -->
<script type="cordys/xml" id="schema">
    <TreeSchema>
        <searchPath>//data/tuple/old/</searchPath>
        <Root>
            <description>Employees</description>
        </Root>
        <TreeItem id="EmployeesID">
            <searchPath>Employees</searchPath>
            <description>FirstName</description>
            <oncollapse>collapseHandler</oncollapse>
        </TreeItem>
    </TreeSchema>
</script>
//Function call
function collapseHandler(collapsedNode)
{
    <!-- Alert data of the collapsed item -->
    application.notify("item collapsed : " + cordys.getXML(collapsedNode.data));
    <!-- Return without collapsing -->
    return false;
}
<!-- tree definition -->
<div cordysType="wcp.library.ui.Tree" id="sampleTree" treeSchema="schema" treeData="data"></div>

See Also


tree